{include file="public/toper"/}
<style>
    .layui-input-inline{width: 34% !important}
    .layui-unselect{width: 100%;}
</style>
<div class="x-body">
    <form action="" method="post" class="layui-form" id="forms">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>推送用户
            </label>
            <div class="layui-input-inline">
                <input type="radio" name="user_id" lay-filter="userid" value="0" title="全部用户">
                <input type="radio" name="user_id" lay-filter="userid" value="1" title="指定用户">
                <input type="text" value="" id="name" autocomplete="off" class="layui-input" readonly="readonly" >
                <input type="hidden" value="" id="userid" name="user_id" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red" id="choice">选择</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>适用范围</label>
            <div class="layui-input-inline">
                <select name="coupons_id">
                    {volist name="list" id="vo"}
                    <option value="{$vo.coupons_id}">【{$vo.scope}】{$vo.name}（{$vo.start_time}至{$vo.settlement_time}）剩{$vo.number-$vo.receive_number}张</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button  class="layui-btn" lay-filter="formSubmit" lay-submit="">提交</button>
        </div>
    </form>
</div>
{include file="public/footer"/}
<script>
    layui.use(['layer','form'], function(){
        var layer = layui.layer;
        var form = layui.form;
        form.on('radio(userid)', function(data){
            if(data.value==0){
                $('#userid').val(0);
                $('#name').val('');
            }else{
                $('#userid').val(1);
            }
        })

        $("#choice").click(function(){
            var userid = $("input:radio[name=\"user_id\"]:checked").val();
            if(userid!=1){
                layer.msg('选择指定用户才能点击选择');
                return false;
            }

            layer.open({
                type: 2,
                title: '选择用户',
                area: ['900px', '650px'],
                fixed: false, //不固定
                maxmin: true,
                content: "{:url('User/choice_array')}"
            });
        });
    });
</script>